package day0302;

import java.util.Calendar;
import java.util.Date;

public class Demo03 {

    public static void main(String[] args) {

        Calendar instance = Calendar.getInstance();
        System.out.println(instance);

//        instance.clear();
//        instance.clear(Calendar.YEAR);
//        System.out.println(instance);

//        System.out.println(instance.get(Calendar.YEAR));
//        System.out.println(instance.getActualMaximum(Calendar.MONTH));
//        System.out.println(instance.getActualMinimum(Calendar.MONTH));

        // 2023 3 2
        System.out.println(instance.getFirstDayOfWeek());

        // Calendar --> Date
        System.out.println(instance.getTime());
        // Date --> Calendar
        instance.setTime(new Date());

        // 日期加减
//        instance.add(Calendar.DAY_OF_MONTH, -3);
//        System.out.println(instance.getTime().toLocaleString());

//        instance.roll(Calendar.DAY_OF_MONTH, -3);
//        System.out.println(instance.getTime().toLocaleString());

        // 设置成
        instance.set(Calendar.DAY_OF_MONTH, 23);
        System.out.println(instance.getTime().toLocaleString());

        // 获取字段
        String s = instance.get(Calendar.YEAR) + "年" + (instance.get(Calendar.MONTH) + 1) + "月" + instance.get(Calendar.DAY_OF_MONTH);
        System.out.println(s);

        instance.add(Calendar.WEEK_OF_MONTH, 1);
        System.out.println(instance.getTime().toLocaleString());

        instance.clear();

        instance.set(Calendar.YEAR, 2023);
        instance.set(Calendar.DAY_OF_YEAR, 61);
        System.out.println(instance.getTime().toLocaleString());

    }
}
